package com.wooboo.server.ext.util;

import java.text.DecimalFormat;

public class NumberUtil {

	public static Integer getInteger(String val,Integer def){
		if(val!=null && !val.isEmpty()){
			 return Integer.valueOf(val);
		}
		return def;
	}
	public static Integer getInteger(String val){
		if(val!=null){
			 return Integer.valueOf(val);
		}
		return null;
	}
	
	public static Double getDouble(String val){
		if(val!=null){
			return Double.valueOf(val);
		}
		return null;
	}
	public static Integer parseInteger(String val,Integer def){
		try{
			return Integer.parseInt(val);
		}catch(Exception e){
			return def;
		}
	}
	public static String formatYuan(Double d,String patten){
		if(null==d){
			return "0.00";
		}
		DecimalFormat df=new DecimalFormat(StringUtil.dealNull(patten, "#0.00")); 
		return df.format(d);
	}
}
